<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.SmsModule.bean.*,com.SmsModule.dao.*,com.UserModule.dao.*"%>  
<%@ page import="util.*" %>
<%
	String startTime = session.getAttribute("startTime").toString();
	String endTime = session.getAttribute("endTime").toString();
	String content=session.getAttribute("content").toString();
	String phone=session.getAttribute("phone").toString();
	System.out.println("startTime---"+startTime+"endTime==="+endTime);
	List<TbSmsSend> SmsSendList = (ArrayList) session.getAttribute("smsSendList");
	  //---------分页
	    int currentPage=1;
	    if(request.getParameter("Page")!=null)
	    {
	    	currentPage=Integer.parseInt(request.getParameter("Page"));
	    }
	//System.out.println("size==" + SmsContentList.size());
%>

<jsp:include page="../head.jsp"></jsp:include>
<body>
<div id="pager">
<jsp:include page="../top.jsp"><jsp:param name="topCurrent" value="1" /></jsp:include>    
<jsp:include page="leftSms.jsp">
<jsp:param name="smsSendStyle" value="13" /></jsp:include> 
		<section id="container">
        <div id="crumbs">
        	短信管理 &raquo; 短信发件箱
        </div>
    <div id="main">
			<div class="tabs">
				<ul class="tabs-nav clearfix">
					<li>
						短信发件箱
					</li>
				</ul>
				<div class="tabs-panel">
				<%
			try{
		 	 String resultSM=session.getAttribute("result").toString();
			 if(!resultSM.equals("")){
				 out.println("<script>alertmess('"+resultSM+"');</script>");
				 session.removeAttribute("result");
			 }
			 }catch(Exception ex){
			 
			 }
		 	%>
				 <form action="" method="post" id="form1" name="form2">
					<table width="100%" class="datalist">
						<thead>
							<tr>
								<th colspan="7" class="tl">
												开始时间
												 <input type="text" id="startTime" size="25" name="startTime" class="Wdate" value="<%=startTime%>" readonly="readonly" onclick="WdatePicker({el:'startTime',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
												结束时间
												<input type="text" id="endTime" size="25" name="endTime" class="Wdate"  value="<%=endTime%>"   readonly="readonly"  onclick="WdatePicker({el:'endTime',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
												短信内容
												<input type="text" id="content" name="content" value="<%=content %>" />
												发送号码
												<input type="text" id="phone" name="phone" maxlength="11" value="<%=phone %>" />
												<input type="button" value="查询" onclick="searcherSM('../TbSmsServlet?method=search')" />&nbsp;&nbsp;
												<input type="button" value="批删" onclick="deleteSmsAllSM('deleteAll','../TbSmsServlet?method=deleteAll&startTime=<%=startTime%>&endTime=<%=endTime%>&content=<%=content %>&phone=<%=phone %>')" />&nbsp;&nbsp;
								</th>
							</tr>
							<tr>
								<td class="tc">
									<input type="checkbox" title="全选" onClick="check_allSM('deleteAll')"/>
								</td>
								<td>
									序号
								</td>
								<td>
									短信内容
								</td>
								<td>
									发送时间
								</td>
								<td>
									接收人
								</td>
								<td>
									发送状态
								</td>
								<td>
									操作
								</td>
							</tr>
						</thead>
						<%
							int i=0; 
							//--------------分页
							//--excel start
							if(SmsSendList!=null)
        					{
					        	//---excel end
								    					MyPagination mPages=new MyPagination();
								     					SmsSendList=mPages.getInitPage(SmsSendList,currentPage,10);
											if (SmsSendList != null && SmsSendList.size() > 0){
												for (TbSmsSend smsSendBean : SmsSendList){
												i++;
								%>
								<tr>
							<td class="tc">
								<input name="deleteAll" id = "deleteAll" type="checkbox" value="<%=smsSendBean.getSmsId() %>"/>
							</td>
				  			<script type="text/javascript">
							$(function(){
				 				$('#demo-basic<%=i%>').poshytip();
							
				   			});
				  			 </script>
				  			 <td><%=((10*(currentPage-1))+i) %></td>
				  			 <td><a id="demo-basic<%=i%>" title="<%=smsSendBean.getSmsContent() %>" href="#"><%=new UtilDAO().sub_String(smsSendBean.getSmsContent()) %></a></td>
							<td><%=smsSendBean.getSendTime()%></td>
							<td><%=smsSendBean.getDestAdd()%></td>
							<td>
							<%
							if(smsSendBean.getSmsSendState()==0){//未发送
							%>
							未发送
							<%
							}else if(smsSendBean.getSmsSendState()==1){//发送成功
							%>
							发送成功
							<%
							}else{//发送失败
							%>
							发送失败
							<%
							}
							 %>
							</td>
							<td class="tc">
							<%
								if(smsSendBean.getSmsSendState()>1){
									%>
									<a title="重发短信" class="duanyu_edit" style="cursor:hand" onclick="confirmmess('你确定重发吗?','../TbSmsServlet?method=sendAgin&smsId=<%=smsSendBean.getSmsId() %>')">重发</a>
									<%
								}
							%>
								
								<a title="删除该短信" class="duanyu_del" style="cursor:hand" 
								onClick="deleteOneSM('../TbSmsServlet?method=deleteOne&smsId=<%=smsSendBean.getSmsId() %>')" >
								删除</a>
							</td>
				  			 </tr>
								<%
											}
											}
											%>
											<%=mPages.printCtrl("SmsModule/SmsList.jsp",currentPage,"&startTime="+startTime+"&endTime="+endTime+"&content="+content+"&phone="+phone)  %>
											<%
											}
						 %>
					</table>
					 
			 </form>
				</div>
		</div>
		</section>
		  <jsp:include page="../foot.jsp"></jsp:include>
		  </div>
		  </div>
		  
	</body>
</html>
